<meta charset="utf-8" />
<div class="breadcrumbs" id="breadcrumbs">
	<ul class="breadcrumb">
		<li><i class="ace-icon fa fa-home home-icon"></i> <a href="index">主数据管理</a>
		</li>

		<li><span>工序管理</span></li>
	</ul>
</div>

<div class="page-content">
	<div class="row">
		<div class="col-xs-12">
			<div class="clearfix"></div>
			<div class="table-header">工序管理</div>
			<div>
				<div id="dynamic-table_wrapper"
					class="dataTables_wrapper form-inline no-footer">
					<div class="row">
						<div class="widget">
							<div class="widget-main">
								<form class="form-inline" id="selefrom" action="wlsjgl/sele"
									method="post">
									工序编码<input type="search" style="width:180px;height:30px "
										 class="form-control input-sm" placeholder="输入查询内容"
										aria-controls="dynamic-table" name="selevalue" id="hhh1">
									工序名称<input type="search" style="width:180px;height:30px "
										 class="form-control input-sm" placeholder="输入查询内容"
										aria-controls="dynamic-table" name="selevalue" id="hhh1">
									<button id="selectfromsb" style="height:30px "
										class="btn btn-info btn-sm">查询</button>
										
									<button id="selectfromcz" style="height:30px "
										class="btn btn-info btn-sm">重置</button>
								</form>
							</div>
							<div class="pull-left" style="margin: 0px 0px 0px 17px;">
								<button onclick="" class="btn btn-info btn-sm" style="margin: 0px 8px 0px 0px;">添加</button>
								<button onclick="" class="btn btn-info btn-sm" style="margin: 0px 8px 0px 0px;">删除</button>
								<button onclick="" class="btn btn-info btn-sm" style="margin: 0px 8px 0px 0px;">导入</button>
								<button onclick="" class="btn btn-info btn-sm" style="margin: 0px 8px 0px 0px;">导出</button>
							</div>
						</div>
					</div>
					<div style="overflow-x: scroll;">
						<table
							class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable"
							id="dynamic-table" role="grid"
							aria-describedby="dynamic-table_info">
							<thead>
								<tr role="row">
									<th class="center" style="width:9px; "><label> <input type="checkbox" class="ace" /> <span class="lbl"></span></label></th>
									<th>工序编码</th>
									<th>工序名称</th>
									<th>所需物料编码</th>
									<th>所需物料名称</th>
									<th>工时</th>
									<th>工作中心</th>
									<th>是否关键工序</th>
									<th>工序产能约束方式</th>
									<th>工序产能时间</th>
									<th>备注</th>
								</tr>
							</thead>
							<tbody id="wlsjtc">
							</tbody>
						</table>
					</div>
					<div class="row">
						<div class="col-xs-12 col-md-12">
							<div class=" pull-left">
								<label>显示<select name="dynamic-table_length"
									aria-controls="dynamic-table" class="form-control input-sm" id="sel">
									    <option value="10">10</option>
										<option value="20">20</option>
										<option value="50">50</option>
										<option value="100">100</option>
								</select> 条记录</label>
							</div>

							<div class="dataTables_paginate paging_simple_numbers ">
								<ul class="pagination" id="dynamic-table_paginate111">
														</ul>
								<div class="dataTables_paginate paging_simple_numbers">
									<div class="laypage_main laypageskin_molv" id="laypage_3">
										<span class="laypage_curr" style="background-color:#2283C5">1</span><span
											class="laypage_total"><label>到第</label><input max="1"
											min="1" class="laypage_skip" type="number"><label>页</label>
											<button type="button" class="laypage_btn">
												确定
												<tton>
										</span>
									</div>
								</div>

							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<!-- 更改每页显示数据的数目 -->
<script type="text/javascript">
	var sel = document.getElementById("sel");
	sel.onchange = function() {
		/* alert(sel.options[sel.selectedIndex].value); */
		$.post("gxgl/gghs", {
			"pageNum" : sel.options[sel.selectedIndex].value
		}, function(data) {
			pagedemo(1);
		});
	}
</script>

<script type="text/javascript">
	pagedemo(1);
	function pagedemo(n) {

		$.post("wlsjgl/pagedemo", {
			"pageNumber" : n,
			"pch" : $("#pch").val()
		}, function(data) {
			pack(data.list); //调用下面pack()方法，填充表格数据

			if (data.totalPage == 1) {
				$("#dynamic-table_paginate111").addClass("hide");
				$("#laypage_3").removeClass("hide");
			} else {
				$("#laypage_3").addClass("hide");
				$("#dynamic-table_paginate111").removeClass("hide");
				laypage({
					cont : $('#dynamic-table_paginate111'), //容器。值支持id名、原生dom对象，jquery对象,
					pages : data.totalPage, //总页数
					skip : true, //是否开启跳页
					skin : '#2283C5',//保持ace中间的样式
					first : 1,
					last : data.totalPage, //总页数，将尾页显示为总页数
					curr : data.pageNumber,//当前页
					groups : 5, //连续显示分页数
					jump : function(obj, first) {
						if (!first) { //一定要加此判断，否则初始时会无限刷新
							pagedemo(obj.curr);
						}
					}
				});
			}
		});
	}

	function pack(data) { //填充数据
		var dataStr = "";
		$.each(data, function(i, v) {
			dataStr += packlist(v);
		});
		$("#wlsjtc").html(dataStr);
	}

	function packlist(v) {
		var dataStr = "";
		dataStr += '<tr>';
		dataStr += '<td class="center" style="width:9px; "><label> <input type="checkbox"class="ace" /> <span class="lbl"></span></label></td>';
		dataStr += '<td><a>' + v.wlbm + '<a></td>';
		dataStr += '<td>' + v.wlmc + '</td>';
		dataStr += '<td>' + v.ggxh + '</td>';
		dataStr += '<td>' + v.dw + '</td>';
		dataStr += '<td>' + v.pp + '</td>';
		dataStr += '<td>' + v.gys + '</td>';
		dataStr += '<td>' + v.gysbm + '</td>';
		dataStr += '<td>' + v.wllx + '</td>';
		dataStr += '<td>' + v.wldj + '</td>';
		dataStr += '<td>' + v.cglx + '</td>';
		dataStr += '<td>' + v.ccq + '</td>';
		dataStr += '<td>' + v.zbq + '</td>';
		dataStr += '<td>' + v.kc + '</td>';
		dataStr += '<td>' + v.zbkc + '</td>';
		dataStr += '<td>' + v.zgkc + '</td>';
		dataStr += '<td>' + v.wlz + '</td>';
		dataStr += '<td>' + v.pcgl + '</td>';
		dataStr += '<td>' + v.hxwl + '</td>';
		dataStr += '<td>' + v.sfjy + '</td>';
		dataStr += '<td>' + v.sczq + '</td>';
		dataStr += '<td>' + v.cgzq + '</td>';
		dataStr += '<td>' + v.kthwl + '</td>';
		dataStr += '<td>' + v.ckwd + '</td>';
		dataStr += '<td>' + v.shl + '</td>';
		dataStr += '<td>' + v.wlzt + '</td>';
		dataStr += '<td>' + v.bz + '</td>';
		dataStr += '</tr>';
		return dataStr;
	};

	/* 撤销查询 */
	$("#selectfromcz").click(function() {
		document.getElementById("hhh1").value = "";
		$.post("wlsjgl/sele", $("#selefrom").serialize(), function(data) {
			pagedemo(1);
		})
		return false;
	});
    //查询选中的类型数据
    $("#selectfromsb").click(function() {
    	var wlcxType = document.getElementById('selectValue').value;
    	console.log(wlcxType);
    	//var value = obj.options[index].value; // 选中值
		$.post("wlsjgl/sele",
		"cxType": wlType,
		$("#selefrom").serialize(), function(data) {
			pagedemo(1);
	});
	
	


	//错误提示(传入错误信息)
	function errorMsg(errorInfo) {
		layer.confirm(errorInfo, {
			btn : [ '确定' ]
		//按钮
		}, function(index) {
			layer.close(index);
		});
	}
</script>
